package org.janon.httpproxy;

import java.util.List;

public class HttpModel
{
	private int methodId = 0;
	private String httpType = null;
	private boolean hasContent = false;
	private byte[] content = null;
	private int contentLength = -1;
	private List<String> requestHeader = null;
	private HttpURL url = null;
	private String userAddr = "";
	private String continueConnectionActID = null;

	public String getMethodString()
	{
		return HttpUtil.getHttpMethod(methodId);
	}

	public int getMethodId()
	{
		return methodId;
	}

	public void setMethodId(int methodId)
	{
		this.methodId = methodId;
	}

	public HttpURL getUrl()
	{
		return url;
	}

	public void setUrl(HttpURL url)
	{
		this.url = url;
	}

	public boolean isHasContent()
	{
		return hasContent;
	}

	public void setHasContent(boolean hasContent)
	{
		this.hasContent = hasContent;
	}

	public byte[] getContent()
	{
		return content;
	}

	public void setContent(byte[] content)
	{
		this.content = content;
	}

	public List<String> getRequestHeader()
	{
		return requestHeader;
	}

	public void setRequestHeader(List<String> requestHeader)
	{
		this.requestHeader = requestHeader;
	}

	public String getHttpType()
	{
		return httpType;
	}

	public void setHttpType(String httpType)
	{
		this.httpType = httpType;
	}

	public String getFirstLine()
	{
		return getMethodString() + " " + getUrl().getUrl() + " " + getHttpType();
	}

	public int getContentLength()
	{
		return contentLength;
	}

	public void setContentLength(int contentLength)
	{
		this.contentLength = contentLength;
	}

	public int getHttpTypeId()
	{
		if (getHttpType() == null || getHttpType().length() != 8)
		{
			return -1;
		}
		else
			return (httpType.charAt(7) - '0');
	}

	public String getUserAddr()
	{
		return userAddr;
	}

	public void setUserAddr(String userAddr)
	{
		this.userAddr = userAddr;
	}

	public String getContinueConnectionActID() {
		return continueConnectionActID;
	}

	public void setContinueConnectionActID(String continueConnectionActID) {
		this.continueConnectionActID = continueConnectionActID;
	}
}
